package com.vector.controller;

import com.vector.utils.ExcelPoiUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileInputStream;
import java.io.IOException;

@Controller
public class FileController {

    @RequestMapping("/readFile")
    public String readFile(@RequestParam("subFileFirst") MultipartFile subFileFirst
            , @RequestParam("subFileSecond") MultipartFile  subFileSecond, Model model) throws IOException {

            ExcelPoiUtils excelPoiUtils = new ExcelPoiUtils();
            excelPoiUtils.queryString((FileInputStream) subFileSecond.getInputStream()
                    ,excelPoiUtils.readText((FileInputStream) subFileFirst.getInputStream()));

            return "welcome";

    }


    @RequestMapping("/toIndex")
    public String toIndex(){
        return "index";
    }

    @RequestMapping("/toIndexTwo")
    public String toIndexTwo(){
        return "indexTwo";
    }

    @RequestMapping("/toSuccess")
    public String toSuccess(){
        return "success";
    }


}
